<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="#{facesContext.externalContext.requestContextPath}../../resources/template/layout.xhtml">

    <ui:define name="content">

        <h:form id="frm-usuario" prependId="false">

            <p:toolbar id="toolbar">

                <p:toolbarGroup align="left">
                    <h1 class="titulo">
                        Formulário de Usuários
                    </h1>
                </p:toolbarGroup>

                <p:toolbarGroup align="right">

                    <p:ajaxStatus style="float: left; width:16px; height:16px; margin: 7px 7px 0px 0px;">  

                        <f:facet name="start">  
                            <h:graphicImage value="#{facesContext.externalContext.requestContextPath}../../resources/img/ajax.gif" />  
                        </f:facet>  

                        <f:facet name="complete">  
                            <h:outputText value="" />  
                        </f:facet>  

                    </p:ajaxStatus>

                    <p:commandButton id="btn-salvar"
                                     value="Salvar"
                                     image="ui-icon ui-icon-disk"
                                     action="#{usuarioBean.salvar()}"
                                     update="grid msg"
                                     title="Salvar"
                                     tabindex="5" />

                    <p:divider />

                    <p:commandButton id="btn-voltar"
                                     image="ui-icon ui-icon-arrowreturnthick-1-w"
                                     immediate="true"
                                     action="list?faces-redirect=true"
                                     title="Página Anterior"/>

                </p:toolbarGroup>

            </p:toolbar>

            <p:spacer height="15" />

            <p:panel id="panel" header="Dados do Usuário">

                <p:messages id="msg" showDetail="true" showSummary="false" />

                <h:panelGrid id="grid" columns="3" cellpadding="5">

                    <h:outputLabel for="nome" value="Nome: " />

                    <p:inputText id="nome" 
                                 value="#{usuarioBean.usuario.nome}"
                                 maxlength="50" 
                                 style="width: 400px;"
                                 tabindex="1"
                                 required="true"
                                 label="Nome" />

                    <p:message for="nome" display="icon" />

                    <h:outputLabel for="login" value="Login: " />

                    <p:inputText id="login" 
                                 value="#{usuarioBean.usuario.login}"
                                 maxlength="10" 
                                 style="width: 110px;"
                                 tabindex="2"
                                 required="true"
                                 label="Login" />

                    <p:message for="login" display="icon" />

                    <h:outputLabel for="senha" value="Senha: " />

                    <p:password id="senha" 
                                value="#{usuarioBean.usuario.senha}"
                                feedback="true"
                                minLength="3"
                                maxlength="10" 
                                style="width: 110px;"
                                label="Senha"
                                promptLabel="Informe uma senha"
                                weakLabel="Fraca" 
                                goodLabel="Boa"
                                strongLabel="Ótima"
                                required="true"
                                tabindex="3">
                        <f:validateLength minimum="3" maximum="10" />
                    </p:password>

                    <p:message for="senha" display="icon" />

                    <h:outputLabel for="tipo" value="Tipo:" />

                    <h:selectOneMenu id="tipo" 
                                     value="#{usuarioBean.usuario.tipo}" 
                                     required="true"
                                     label="Tipo"
                                     tabindex="4">

                        <f:selectItems value="#{usuarioBean.tipoUsuarioValues}" 
                                       var="tipo" 
                                       itemValue="#{tipo}" 
                                       itemLabel="#{tipo.label}" />

                    </h:selectOneMenu>

                    <p:message for="tipo" display="icon" />

                </h:panelGrid>

            </p:panel>

        </h:form>

    </ui:define>

</ui:composition>